package com.party.core.model.message;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * Created by wei.li
 *
 * @date 2017/9/8 0008
 * @time 10:06
 */
public enum IdentityType {

    NORMAL("NORMAL", "普通用户"),

    OFFICIAL_PARTNER("OFFICIAL_PARTNER", "合作商"),

    PARTNER("PARTNER", "合伙人"),

    CHANNEL_DIS("CHANNEL_DIS", "渠道分销商"),

    COSPONSOR("COSPONSOR", "合作渠道");

    private String code;

    private String value;

    IdentityType(String code, String value) {
        this.code = code;
        this.value = value;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static String getValue(String code) {
        for (IdentityType identityType : IdentityType.values()) {
            if (code.equals(identityType.getCode())) {
                return identityType.getValue();
            }
        }
        return null;
    }

    public static Map<String, String> convertMap() {
        Map<String, String> map = Maps.newHashMap();
        for (IdentityType identityType : IdentityType.values()) {
            map.put(identityType.getCode(), identityType.getValue());
        }
        return map;
    }
}
